# -*- coding:utf-8 -*-
# @FileName  :dhcc_per_dic.py
# @Time      :2020/12/10 14:27
# @Author    :Zhoujirong
# @Desc      :个人业务字典

from biz.flow.per_dic import PerDicRequest
from common.log import Log
from biz.cases.base_case import BaseCase

class TestPerDic(BaseCase):
    data_file_name = 'business_dic.yaml'
    @classmethod
    def setUpClass(cls):
        cls.cookie = BaseCase().get_token()
    def test_a_create(self):
        '''新建业务字典'''
        type = self.file_data.get('type')
        value = self.file_data.get('value')
        code = self.file_data.get('code')
        remark = self.file_data.get('remark')
        ret = PerDicRequest.create_dic(type,value,code,remark,self.cookie)
        Log.info(ret)
        self.assertEqual('00000000', ret.code)
        self.assertIn('操作成功', ret.msg)

    def get_page(self):
        '''检索'''
        curPage = self.file_data.get('curPage')
        maxSize = self.file_data.get('maxSize')
        search_LIKE_type = self.file_data.get('search_LIKE_type')
        search_LIKE_value = self.file_data.get('search_LIKE_value')
        ret = PerDicRequest.get_page(curPage,maxSize,search_LIKE_type,search_LIKE_value,self.cookie)
        Log.info(ret)
        remark = self.file_data.get('remark')
        self.assertEqual(remark,ret.list[0].remark)
        return ret.list[0].id

    def test_b_detail(self):
        '''业务字典详情'''
        id = self.get_page()
        ret = PerDicRequest.detail(id,self.cookie)
        Log.info(ret)
        self.assertEqual(id,ret.id)

    def test_c_update(self):
        '''业务字典编辑'''
        checked = self.file_data.get('checked')
        code = self.file_data.get('code')
        ext1 = self.file_data.get('ext1')
        ext2 = self.file_data.get('ext2')
        ext3 = self.file_data.get('ext3')
        ext4 = self.file_data.get('ext4')
        ext5 = self.file_data.get('ext5')
        ext6 = self.file_data.get('ext6')
        id = self.get_page()
        remark = self.file_data.get('remark_update')
        resCode = self.file_data.get('resCode')
        resMsg = self.file_data.get('resMsg')
        serialNumber = self.file_data.get('serialNumber')
        type = self.file_data.get('type')
        value = self.file_data.get('value_update')
        ret = PerDicRequest.update(checked,
                    code,
                    ext1,
                    ext2,
                    ext3,
                    ext4,
                    ext5,
                    ext6,
                    id,
                    remark,
                    resCode,
                    resMsg,
                    serialNumber,
                    type,
                    value,self.cookie)
        Log.info(ret)
        self.assertEqual('00000000', ret.code)
        self.assertIn('操作成功', ret.msg)

    def get_page2(self):
        '''检索编辑后的数据'''
        curPage = self.file_data.get('curPage')
        maxSize = self.file_data.get('maxSize')
        search_LIKE_type = self.file_data.get('search_LIKE_type')
        search_LIKE_value = self.file_data.get('search_LIKE_value')
        ret = PerDicRequest.get_page(curPage, maxSize, search_LIKE_type, search_LIKE_value, self.cookie)
        Log.info(ret)
        remark = self.file_data.get('remark_update')
        self.assertEqual(remark, ret.list[0].remark)
        return ret.list[0].id

    def test_d_del(self):
        '''业务字典删除'''
        ids = self.get_page2()
        ret = PerDicRequest.delete(ids,self.cookie)
        Log.info(ret)
        self.assertEqual('00000000', ret.code)
        self.assertIn('操作成功', ret.msg)






if __name__ == "__main__":
    pass